from datetime import datetime
from typing import List

from pydantic import BaseModel
from decimal import Decimal

from app.schemas.simulation_result import SimulationResultOut


class SimulationResultTotalCreate(BaseModel):
    env_param_id: int
    battery_energy: Decimal
    solar_power: Decimal
    grid_power: Decimal
    wind_power: Decimal
    total_power: Decimal
    solar_cost: Decimal
    wind_cost: Decimal
    grid_cost: Decimal
    solar_emission: Decimal
    wind_emission: Decimal
    grid_emission: Decimal
    period_unit: str
    period: int
    name: str
    strategy: str
    simulation_id: int

    class Config:
        from_attributes = True  # 父类必须有


class SimulationResultTotalOut(SimulationResultTotalCreate):
    simulation_result_total_id: int
    class Config:
        from_attributes = True  # 这里也要写

class SimulationResultTotalSchema(BaseModel):
    simulation_result_total_id: int
    battery_energy: float
    solar_power: float
    grid_power: float
    wind_power: float
    total_power: float
    solar_cost: float
    wind_cost: float
    grid_cost: float
    solar_emission: float
    wind_emission: float
    grid_emission: float
    period_unit: str
    period: int
    name: str
    strategy: str
    simulation_id: int

    class Config:
        from_attributes = True

class SimulationResultTotalOutDetail(BaseModel):
    simulation_result_total_id: int
    env_param_id: int
    battery_energy: Decimal
    solar_power: Decimal
    grid_power: Decimal
    wind_power: Decimal
    total_power: Decimal
    solar_cost: Decimal
    wind_cost: Decimal
    grid_cost: Decimal
    solar_emission: Decimal
    wind_emission: Decimal
    grid_emission: Decimal
    period_unit: str
    period: int
    name: str
    results: List[SimulationResultOut]

    class Config:
        from_attributes = True